package org.black.missedCall2.reply;

import java.util.List;
import java.util.Vector;

import org.black.missedCall2.R;
import org.black.missedCall2.reply.dataModel.BaseReplyListDataModel;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;

public class ReplyListActivity extends Activity {
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.reply_list);

		Button addMissedCallReplyButton = (Button) this
				.findViewById(R.id.addMissedCallReplyButton);
		addMissedCallReplyButton.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setClass(ReplyListActivity.this, AddReplyActivity.class);

				startActivity(intent);
				Log.i(ReplyConstant.REPLY_TAG, "Switch to AddReplyActivity.");
			}
		});

		ListView listView = (ListView) ReplyListActivity.this
				.findViewById(R.id.missedCallReplyListView);
		listView.setItemsCanFocus(false);
		listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
		// listView.setEmptyView(noMissedCallTextView);
		listView.setDivider(new ColorDrawable(Color.WHITE));
		listView.setDividerHeight(1);
		List<BaseReplyListDataModel> data = new Vector<BaseReplyListDataModel>();
		BaseReplyListDataModel b1 = new BaseReplyListDataModel();
		b1.setListenForId(1l);
		b1.setListenForName("abc");
		b1.setListenForNumbers(null);
		b1.setMessage("def");
		b1.setResponseToId(2l);
		b1.setResponseToNumbers(null);
		b1.setResponseToName("def");

		BaseReplyListDataModel b2 = new BaseReplyListDataModel();
		b2.setListenForId(1l);
		b2.setListenForName("abc");
		b2.setListenForNumbers(null);
		b2.setMessage("def");
		b2.setResponseToId(2l);
		b2.setResponseToNumbers(null);
		b2.setResponseToName("def");
		data.add(b1);
		data.add(b2);
		ReplyListAdapter missedCallAdapter = new ReplyListAdapter(this, data);
		ListAdapter listAdapter = listView.getAdapter();
		if (listAdapter != null) {
			((ReplyListAdapter) listAdapter).notifyDataSetChanged();
		}
		listView.setAdapter(missedCallAdapter);
	}
}
